package com.aimer.adapter;

import android.graphics.Color;
import android.widget.BaseAdapter;

import androidx.annotation.Nullable;


import com.aimer.model.HomeModel;
import com.anime.R;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

public  class HomeAdapter  extends BaseQuickAdapter<HomeModel, BaseViewHolder>{
    private int index;

    public HomeAdapter(int layoutResId, @Nullable @org.jetbrains.annotations.Nullable List<HomeModel> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, HomeModel item) {

        helper.setText(R.id.tv_title,item.getName());
        helper.setImageResource(R.id.iv_pig,item.getPig1());


        if(index==helper.getAdapterPosition()){
            helper.setImageResource(R.id.iv_pig,item.getPig2());
            helper.setTextColor(R.id.tv_title, Color.parseColor("#FFC0CB"));
        }else {
            helper.setImageResource(R.id.iv_pig,item.getPig1());
            helper.setTextColor(R.id.tv_title, Color.parseColor("#C9CBCD"));
        }
    }

    public void setIndex(int index) {
        this.index= index ;
    }
}
